# Maintainer: Felix Yan <felixonmars@archlinux.org>
# Maintainer: Daniel M. Capella <polyzen@archlinux.org>
# Contributor: Ismael Carnales <icarnales at gmail dot com>
# Contributor: Sergey Mastykov <smastykov[at]gmail[dot]com>

pkgname=python-pycodestyle
pkgver=2.11.1
pkgrel=1
pkgdesc="Python style guide checker"
arch=('any')
url="https://pycodestyle.pycqa.org"
license=('custom:Expat')
depends=('python')
makedepends=(
  'python-build'
  'python-installer'
  'python-setuptools'
  'python-wheel'
)
checkdepends=('python-pytest')
source=("https://github.com/PyCQA/pycodestyle/archive/$pkgver/$pkgname-$pkgver.tar.gz")
sha512sums=('8e1f302d7e26d56edd924202435caef32369ea13eb4a0fdfb48c06bb5d77fd7a5aef92d470eef3e6fdd9c3b298751a52a83317e9ddf8b2aa7e3fedc75fb5151a')

build() {
  cd pycodestyle-$pkgver
  python -m build --wheel --skip-dependency-check --no-isolation
}

check() {
  cd pycodestyle-$pkgver
  python -m unittest discover
}

package() {
  cd pycodestyle-$pkgver
  python -m installer --destdir="$pkgdir" dist/*.whl

  # Symlink license file
  local site_packages=$(python -c "import site; print(site.getsitepackages()[0])")
  install -d "$pkgdir"/usr/share/licenses/$pkgname
  ln -s "$site_packages"/pycodestyle-$pkgver.dist-info/LICENSE \
    "$pkgdir"/usr/share/licenses/$pkgname/LICENSE
}

# vim:set ts=2 sw=2 et:
